import java.io.*;
import java.math.*;
//Not working
public class IsolatedPrimes {
	public static void main(String[] args) {
        int x=0,a=0,b=0;
        String p="";
        String x1="",a1="",b1="";
        try{
        	BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
        	x1=read.readLine();
        	a1=read.readLine();
        	b1=read.readLine();
        }
        catch(Exception ex){ex.printStackTrace();}
        x=Integer.parseInt(x1);
        a=Integer.parseInt(a1);
        b=Integer.parseInt(b1);
        p=findPrime(x,a,b);
        System.out.println(p);
        System.exit(0);
	}
    public static String findPrime(int x,int a,int b){
    	String result="";
    	long start=a+2;
    	long end1=b+1;
    	long end=1;
    	for(int i=1;i<20;i++)end=end*2;
    	end=end-end1;
    	long current=start;
    	int number=0;
a:
    	while(current<end){
    		number=0;
    		long start1=current-a;
    		long end11=current+b;
    		long current1=start1;
    		Long current5=new Long(current);
    		BigInteger current6=new BigInteger(current5.toString());
    		if(current6.isProbablePrime(10))
    		while(current1<end11){
    			Long current2=new Long(current1);
    			String current3=current2.toString();
    			BigInteger current4=new BigInteger(current3);
    			if(current4.isProbablePrime(10))number++;
    			current1++;
    		}
    		if(number>0&&number<=x){
    			result=new Long(current).toString();
    			break a;
    		}
    		current++;
    	}
    	
    	return result;
    }
}
